package main

import "fmt"

// Number 泛型指定类型
type Number interface {
	int64 | float64
}

func main() {
	intMap := map[string]int64{
		"first":  34,
		"second": 12,
	}

	floatMap := map[string]float64{
		"first":  34.23,
		"second": 12.99,
	}
	fmt.Println()
	fmt.Printf("Non-Generic Sums: %v and %v ",
		SumInts(intMap),
		sumFloats(floatMap),
	)
	fmt.Println()
	fmt.Printf("Generic Sums: %v and %v ",
		//直接可以识别泛型
		SumGenerics(intMap),
		//显示声明泛型
		SumGenerics[string, float64](floatMap),
	)
	fmt.Println("")
}
